#include "view_time_1.h"
#include "view_time_1.inc"
#include "view_time_0.h"
#include "display_ctrl.h"
#include "platform_assert.h"
#include "lfs_file_manager_auto.h"
#include "rtc.h"
#include "datetime.h"
#include "blecom.h"
#include "battery_ctrl.h"
#include "sport_his.h"
#include "display_ctrl.h"
#include "display_interface_240x240.h"
#include "datetime.h"
#include "heart_rate_interface.h"
#include "font/num_font.h"
#include "font_mngr.h"
#include "view_common.h"
#include "app_trace.h"
#include "weather_ctrl.h"
#include "view_times.h"
#include "math.h"
#ifdef TIME_1_SKIP
#else
static void view_time_1_background(void)
{
	_disp_show_flash_img(DISP_LFS_FILE_INDEX_0,0,0,FILE_IMG_back_red);
}

static void view_time_1_time(void)
{
	int x = 48;
	int y = 37;
	int front_width = 14;
	int front_height = 23;
	int front_width_spacing = 3;
	int front_height_spacing = 12;
	disp_draw_user_image_filter_color(x,y,img_time_1_time_num_TAB[disp_ctrl.com_data.i_temp[3]/10]);
	disp_draw_user_image_filter_color(x+front_width+front_width_spacing,y,img_time_1_time_num_TAB[disp_ctrl.com_data.i_temp[3]%10]);
	disp_draw_user_image_filter_color(x,y+front_height_spacing+front_height,img_time_1_time_num_TAB[disp_ctrl.com_data.i_temp[4]/10]);
	disp_draw_user_image_filter_color(x+front_width+front_width_spacing,y+front_height_spacing+front_height,img_time_1_time_num_TAB[disp_ctrl.com_data.i_temp[4]%10]);
}

static void view_time_1_time_hand(void)
{
	  if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.com_data.i_temp[31] = (RTCGetSeconds() % 60) * 6;
        uint16_t temp16 = get_present_day_minute();
        disp_ctrl.com_data.i_temp[33] = (temp16 / 2) / 6 * 6 % 360;
        disp_ctrl.com_data.i_temp[32] = (temp16 * 6) / 6 * 6 % 360;
    }
    disp_draw_img_rotate(img_time_1_time_hour_hand, 0, 29 , (64 << 16) | 110, disp_ctrl.com_data.i_temp[33]);
    disp_draw_img_rotate(img_time_1_time_minute_hand, 0, 41, (64 << 16) | 110, disp_ctrl.com_data.i_temp[32]);
    disp_draw_img_rotate(img_time_1_time_second_hand, 0, 61 , (64 << 16) | 110, disp_ctrl.com_data.i_temp[31]);
}

void view_time_1_display(void)
{
	view_time_1_background();
	view_time_1_time();
	view_time_1_time_hand();
	show_time_0_ble(disp_ctrl.com_data.i_temp[6]);
  show_time_0_battery(disp_ctrl.com_data.i_temp[7]);
}
#endif
